package com.example.shardingjdbcdemo.config;

import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;

import java.util.Arrays;
import java.util.Collection;

public class Config implements StandardShardingAlgorithm<String> {
    public Config() {
        System.out.println("yes");
    }

    @Override
    public String doSharding(Collection<String> collection, PreciseShardingValue<String> preciseShardingValue) {

        String table = "aqb_pay_" + (int) (Math.random() * 1024);

        // System.out.println(table);
        return table;
    }

    @Override
    public Collection<String> doSharding(Collection<String> collection, RangeShardingValue<String> rangeShardingValue) {
        String table = "aqb_pay_" + (int) (Math.random() * 1024);

        // System.out.println(table);
        return Arrays.asList(table);
    }


}
